package com.noble.glamour.ui.qiniu.play;

import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;

import com.noble.glamour.R;
import com.noble.glamour.module.logic.application.ModuleMgr;
import com.noble.glamour.module.util.UIShow;
import com.noble.glamour.ui.agora.RtcUIShow;
import com.noble.glamour.ui.agora.act.video.RtcChatInputPanel;
import com.noble.glamour.ui.utils.NoDoubleClickListener;
import com.noble.library.view.base.BasePanel;
import com.noble.library.view.CustomFrameLayout;

/**
 * 男性： 视频播放页底部
 * Created by Su on 2017/11/15.
 */
public class PLPlayFootPanel extends BasePanel {
    private LinearLayout inputContainer;
    private CustomFrameLayout inputLayout;
    private RtcChatInputPanel inputPanel;

    public PLPlayFootPanel(Context context) {
        super(context);
        setContentView(R.layout.pl_play_foot_panel);
        initView();
    }

    private void initView() {
        // 聊天输入框
        inputLayout = (CustomFrameLayout) findViewById(R.id.input_layout);
        inputLayout.show(R.id.chat_bottom);
        inputContainer = (LinearLayout) findViewById(R.id.chat_input_panel);
        inputPanel = new RtcChatInputPanel(getContext());
        inputContainer.addView(inputPanel.getContentView());
        inputPanel.setInputPanelListener(new RtcChatInputPanel.InputPanelListener() {
            @Override
            public void onInputbtnClick(View v) {
                refreshLayout();
            }
        });

        findViewById(R.id.msg_chat).setOnClickListener(listener);
        findViewById(R.id.msg_text).setOnClickListener(listener);
        findViewById(R.id.video_chat).setOnClickListener(listener);
        findViewById(R.id.voice_chat).setOnClickListener(listener);
        findViewById(R.id.pl_gift).setOnClickListener(listener);
    }

    /**
     * 更新弹框布局
     */
    public void refreshLayout() {
        inputLayout.show(R.id.chat_bottom);
        inputPanel.refresh(View.GONE);
    }

    private NoDoubleClickListener listener = new NoDoubleClickListener() {
        @Override
        public void onNoDoubleClick(View v) {
            switch (v.getId()) {
                case R.id.msg_chat:     // 发送文字
                case R.id.msg_text:     // 发送文字
                    inputLayout.show(R.id.chat_input_panel);
                    inputPanel.refresh(View.VISIBLE);
                    break;

                case R.id.video_chat:    // 发起视频通话
                    break;

                case R.id.voice_chat:    // 发起音频
                    break;

                case R.id.pl_gift:
                    RtcUIShow.showRtcBottomGiftDlg(getContext(), ModuleMgr.getRtcEnginMgr().getEngineConfig().mOtherId);
                    break;
            }
        }
    };
}